package com.lengtouzai.databaseexp.view.workexperience;

import com.lengtouzai.databaseexp.entity.User;
import com.lengtouzai.databaseexp.entity.WorkExperience;
import com.lengtouzai.databaseexp.view.main.MainView;
import com.vaadin.flow.router.Route;
import io.jmix.core.security.CurrentAuthentication;
import io.jmix.flowui.model.InstanceContainer;
import io.jmix.flowui.view.*;
import org.springframework.beans.factory.annotation.Autowired;

@Route(value = "workExperiences/:id", layout = MainView.class)
@ViewController("exp_WorkExperience.detail")
@ViewDescriptor("work-experience-detail-view.xml")
@EditedEntityContainer("workExperienceDc")
public class WorkExperienceDetailView extends StandardDetailView<WorkExperience> {
    @ViewComponent
    private InstanceContainer<WorkExperience> workExperienceDc;
    @Autowired
    private CurrentAuthentication currentAuthentication;

    @Subscribe
    public void onReady(final ReadyEvent event) {
        workExperienceDc.getItem().setUser((User) currentAuthentication.getUser());
    }
}